home *** CD-ROM | disk | FTP | other *** search
- Path: hubcap.clemson.edu!hubcap!mjs
- From: mjs@hubcap.clemson.edu (M. J. Saltzman)
- Newsgroups: comp.lang.c
- Subject: Re: Unable to check calloc's return values
- Date: 31 Jan 96 15:02:01 GMT
- Organization: Clemson University
- Message-ID: <mjs.823100521@hubcap>
- References: <4emept$ifv@hpg30a.csc.cuhk.hk> <9601311141.AA03713@dxmint.cern.ch>
- NNTP-Posting-Host: hubcap.clemson.edu
-
- Dan Pop <danpop@mail.cern.ch> writes:
-
- |>What's the right way to check the calloc's return value?
-
- | #include <stdlib.h>
- | float **x;
- | if ((x = calloc(9, sizeof(float *))) == NULL) exit(EXIT_FAILURE);
- | /* or, using your style:
- | if ((x = (float **) calloc(9, sizeof(float *))) == 0) exit(1);
- | */
-
- |Note that the effect of exit(1) is implementation defined.
- |There are implementations where it means successful termination.
-
- Also, remember that initializing arrays of floats, doubles, or
- pointers using calloc() is not portable.
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
-